/*
********************************************************************************
* Copyright (C) 2021, xiang.D <dx_65535@163.com>.
* All right reserved.
*
* File Name   : main.cc
* Author      :
* Version     : V1.0
* Description :
* Journal     : 2022-02-13 version v1.0
* Brief       : Blog: https://blog.csdn.net/qq_38750572?spm=1001.2014.3001.5343
* Others      :
                Compile command: make
********************************************************************************
*/
#include <stdio.h>
#include "led_manager_proxy.h"

#define MAIN_LOGI(fmt, args...) printf(fmt, ##args)
#define MAIN_LOGD(fmt, args...) printf("%d Main D: " fmt, __LINE__, ##args)
#define MAIN_LOGW(fmt, args...) printf("%d Main W: " fmt, __LINE__, ##args)
#define MAIN_LOGE(fmt, args...) printf("%d Main E: " fmt, __LINE__, ##args)
#define MAIN_LOG(fmt, args...)  printf(fmt, ##args)

#define LED1 1

static void print_info(void)
{
    MAIN_LOG(
        "a: open light\n"
        "b: show horse light\n"
        "c: show breath light\n"
        "d: close led\n"
        "h: help\n"
        "q: quit\n"
    );
}

int main(int argc, char *argv[])
{
    char input = 0;
    CLedManagerProxy theLedManagerProxy;

    print_info();
    do {
        MAIN_LOG("Input case: ");
        input = fgetc(stdin);
        getchar();

        switch (input)
        {
            case 'a':
                theLedManagerProxy.OpenLight(LED1);
            break;

            case 'b':
                theLedManagerProxy.ShowHorseLight(LED1);
            break;

            case 'c':
                theLedManagerProxy.ShowBreathLight(LED1);
            break;

            case 'd':
                theLedManagerProxy.Stop(LED1);
            break;

            case 'h':
                print_info();
            break;

            default:
                MAIN_LOG("No this case (%c).\n", input);
            break;
        }
    } while(input != 'q');
    return 0;
}
